package day04;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Shuffle {
    static void shuffle(int[] a) {
        int n = a.length;
        for (int i = 0; i < n; i++) {
            // int j = (int) (Math.random() * n);//0,n-1
            int j = (int) (Math.random() * (n - i)) + i;//i,n-1
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }

    public static void main(String[] args) {
        int[] a = new int[]{1, 2, 3, 4};
        shuffle(a);
        System.out.println(Arrays.toString(a));

    }


}